import { create } from 'zustand'
import { createJSONStorage, persist } from 'zustand/middleware'
import globalConfig from '@/core/framework/config/globalConfig'
import { LayoutState } from '@/ui/antd/types/model/dto/LayoutState'
import PageResponse from '@/core/framework/types/model/response/PageResponse'

const useLayoutStore = create(
	persist<LayoutState>(
		(setState, getState) => {
			return {
				isCollapse: false,
				updateCollapse: (collapse: boolean) => {
					setState({ isCollapse: collapse })
				},
			} as LayoutState
		},
		{
			name: `${globalConfig.storageKeyPrefix}.app.global`,
			storage: createJSONStorage(() => localStorage),
		},
	),
)

export default useLayoutStore
